package com.xjy.headfirst.迭代器;

/**
 * decription:
 *
 * @author 辛纪元
 * @since 2022-07-15
 */

public class DinerMenu{

    static final int MAX_ITEMS = 6;

    int numberOfItems = 0;

    MenuItem[] menuItems;

    public DinerMenu() {
        menuItems = new MenuItem[MAX_ITEMS];
        addItem("xjy", "辛1", true, 3.1);
        addItem("jy", "金1", false, 4.2);
    }

    void addItem(String name, String description, boolean vegetarian, double price) {
        MenuItem menuItem = new MenuItem(name, description, vegetarian, price);
        if (numberOfItems >= MAX_ITEMS) {
            System.out.println("满了");
        } else {
            menuItems[numberOfItems] = menuItem;
            numberOfItems = numberOfItems + 1;
        }
    }

    public Iterator createIterator(){
        return new DinerMenuIterator(menuItems);
    }

//    public MenuItem[] getMenuItems(){
//        return menuItems;
//    }

}
